nice_things/fs/glob.sh
glob
Since 0.3.0 · Source
import "{ glob }" from nice_things/fs/glob.sh
Synopsisglob <pattern>…
Configuration
–
Description
Perform pathname expansion (AKA globbing) on arguments. Prints a List of matched files.
Compared to pathname expansion as performed by the shell, this function behaves differently in that it does not print out the input pattern if that pattern fails to match any files.
This function includes a pure sh implementation of globstar, similar to that feature in bash. It works on any shell. You can use the globstar operator ** (double-asterisks) in a path segment to expand any number of subdirectories recursively. Only a single globstar in <pattern> will be treated as such. In case <pattern> contains multiple globstar operators, the later ones will be treated as if they were the single asterisk operator.
Warning
This function prints a
Listand can only be safely used instrict_mode.
Options
–
Operands<pattern>: A glob pattern.
Stdin
–
Stdout
A List of matched files. Each <pattern> can expand to zero or more filenames.
Stderr
–
Exit status0: Successful completion.
Abort
–
Usage examples
#{{{ strict_mode }}}
# Get all sh files in current and child directories
shell_scripts=$(glob ./**/*.sh)